function _ajax({ url, method, headers, body }) {
    return new Promise(function (resolve, reject) {
        let xhr = new XMLHttpRequest();

        xhr.open(method, url);
        
        for (let key in headers) {
            xhr.setRequestHeader(key, headers[key])
        }

        xhr.onreadystatechange = function () {
            if (xhr.readyState === 4) {
                if (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) {
                    resolve(xhr.responseText);
                } else {
                    reject(xhr)
                }
            }
        }

        xhr.send(body)

    })
}